package com.zzz.controller;

import com.zzz.utils.IpUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * @author zhuzhizun
 * @date 2021/7/29
 */

@RestController
public class IpController {

    @GetMapping("/getIp")
    public ResponseEntity<HashMap> getIp(HttpServletRequest request){
        HashMap<String, String> map = new HashMap<>(2);
        String ip = IpUtil.getIp(request);
        String cityInfo = IpUtil.getHttpCityInfo(ip);
        map.put("ip",ip);
        map.put("cityInfo",cityInfo);
        return new ResponseEntity<HashMap>(map, HttpStatus.OK);


    }


}
